﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.PopulationUI {
    import flash.utils.*;
    import org.aswing.*;
    import Classes.*;
    import Display.*;
    import flash.text.*;
    import Display.aswingui.*;
    import Engine.*;

    public class PopulationPopupView extends NotifyPopupView {

        protected var m_popNumber:JTextField;
        protected var m_happiness:JTextField;
        protected var m_popup:PopulationPopup;

        public function PopulationPopupView(_arg1:Dictionary, _arg2:String="", _arg3:String="", _arg4:int=0, _arg5:Function=null, _arg6:PopulationPopup=null){
            super(_arg1, _arg2, _arg3, _arg4, _arg5);
            this.m_popup = _arg6;
            m_state = STATE_LONG;
        }
        override protected function makeCenterPanel():void{
            this.setBackgroundDecorator(new AssetBackground(m_bgAsset));
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanelVertical();
            _local1.append(ASwingHelper.verticalStrut(5));
            switch (m_state){
                case STATE_LONG:
                    _local1.append(this.makeLongPanel());
                    break;
                case STATE_SHORT:
                    _local1.append(this.makeShortPanel());
                    break;
            };
            _local1.append(ASwingHelper.verticalStrut(7));
            ASwingHelper.prepare(_local1);
            this.appendAll(ASwingHelper.horizontalStrut(10), _local1, ASwingHelper.horizontalStrut(3));
            ASwingHelper.prepare(this);
        }
        override protected function makeLongPanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.TOP, -10);
            _local1.appendAll(ASwingHelper.verticalStrut(13), this.makeLongPopulationPanel(), ASwingHelper.verticalStrut(15));
            var _local2:int = Global.world.citySim.getHappinessState();
            this.m_happiness = ASwingHelper.makeTextField(ZLoc.t("Main", ("HappinessState_" + _local2)), EmbeddedArt.DEFAULT_FONT_NAME_BOLD, 13, EmbeddedArt.greenTextColor);
            _local1.append(this.m_happiness);
            ASwingHelper.prepare(_local1);
            if (!Global.isVisiting()){
                m_tip = ASwingHelper.makeMultilineText(ZLoc.t("Main", ("PopulationPopupTip_" + _local2)), 180, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, TextFormatAlign.LEFT, 12, EmbeddedArt.blueTextColor);
                ASwingHelper.setEasyBorder(m_tip, 5, 3);
                _local1.append(m_tip);
            };
            _local1.append(ASwingHelper.verticalStrut(28));
            ASwingHelper.prepare(_local1);
            return (_local1);
        }
        protected function makeLongPopulationPanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanelVertical();
            _local1.setPreferredWidth(180);
            _local1.setMinimumWidth(180);
            var _local2:JPanel = new JPanel(new BorderLayout());
            var _local3:JPanel = ASwingHelper.makeSoftBoxJPanel();
            var _local4:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.LEFT, -3);
            var _local5:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.RIGHT, -3);
            var _local6:JLabel = ASwingHelper.makeLabel((ZLoc.t("Main", "PopulationPopup") + " "), EmbeddedArt.DEFAULT_FONT_NAME_BOLD, 13, EmbeddedArt.orangeTextColor, JLabel.LEFT);
            var _local7:JLabel = ASwingHelper.makeLabel((ZLoc.t("Main", "PopulationCap") + " "), EmbeddedArt.DEFAULT_FONT_NAME_BOLD, 13, EmbeddedArt.orangeTextColor, JLabel.LEFT);
            _local4.appendAll(_local6, _local7);
            _local3.appendAll(ASwingHelper.horizontalStrut(3), _local4);
            ASwingHelper.prepare(_local3);
            var _local8:JLabel = ASwingHelper.makeLabel((Utilities.formatNumber(Global.world.citySim.getScaledPopulation()) + "  "), EmbeddedArt.DEFAULT_FONT_NAME_BOLD, 13, EmbeddedArt.orangeTextColor, JLabel.RIGHT);
            var _local9:JLabel = ASwingHelper.makeLabel((Utilities.formatNumber(Global.world.citySim.getScaledPopulationCap()) + "  "), EmbeddedArt.DEFAULT_FONT_NAME_BOLD, 13, EmbeddedArt.orangeTextColor, JLabel.RIGHT);
            _local5.appendAll(_local8, _local9);
            ASwingHelper.prepare(_local5);
            _local2.append(_local3, BorderLayout.WEST);
            _local2.append(_local5, BorderLayout.EAST);
            ASwingHelper.prepare(_local2);
            _local1.append(_local2);
            ASwingHelper.prepare(_local1);
            return (_local1);
        }
        override protected function makeShortPanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            var _local2:JTextField = ASwingHelper.makeTextField((ZLoc.t("Main", "Population", {amount:Utilities.formatNumber(Global.world.citySim.getScaledPopulation())}) + "  "), EmbeddedArt.TITLE_FONT, 18, EmbeddedArt.blueTextColor);
            this.m_popNumber = ASwingHelper.makeTextField(((String(Global.world.citySim.getScaledPopulation()) + "/") + Utilities.formatNumber(Global.world.citySim.getScaledPopulationCap())), EmbeddedArt.TITLE_FONT, 20, EmbeddedArt.darkBlueTextColor);
            ASwingHelper.setEasyBorder(_local2, 0, 0, 10);
            _local1.appendAll(_local2, this.m_popNumber);
            ASwingHelper.prepare(_local1);
            return (_local1);
        }

    }
}//package Display.PopulationUI 
